<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends BaseController {
    public function index(){
       /* $bnts ='';
        if(S($bnts))
            $btns = S('$btns');
        else {
            $priModel = D('privilege');
            $btns = $priModel->getBtns();
            S('btns', $btns);
        }*/
        $priModel = D('privilege');
        $btns = $priModel->getBtns();
//        dump($btns);exit();
            $this->assign([
                'btns' =>$btns,
            ]);
        $this->display();
    }
    public function welcome(){

        if(session("admin.company_id"))
        {
            $where['company_id'] = session("admin.company_id");
        }
        //默认时间是当前的一个月以内
//        $lastmonth = time()-(86400*30);
//        $where['yueyu_time'] = array(array("egt",date("Y-m-d H:i:s",$lastmonth)),array("elt",date("Y-m-d H:i:s",time())));
        $this->yuyuecount = M("yuyue")->where($where)->count();  //预约人数统计

//        unset($where['yueyu_time']);
//        $where['start_time'] = array("lt",date("Y-m-d H:i:s",time()));
//        $where['end_time'] = array("gt",date("Y-m-d H:i:s",time()));
        $this->membercount = M('member')->where($where)->count(); //客户人数

        $memberbirthday = M('member')->where($where)->select();
        $ss = 0;
        foreach ($memberbirthday as $v)
        {

            $bir = date("Y",time()).substr($v['birthday'],4);
            $strtotime = strtotime($bir);
//            var_dump($strtotime);
            $nowtime = time()+(86400*30);
            if($nowtime>$strtotime)
            {
                $ss++;
            }
        }
        $this->memberbirthday =  $ss;
        //echo M()->_sql();
        $this->display();
    }
}